package org.happylearn.jdk.concurrent;

/**
 * 线程的创建
 * @author ljh
 *
 */
public class ThreadCreator {
	
	
	public static void main(String[] args) {
		Thread t = new MyThread();
		t.setName("myThread");
		//t.run();
		t.start(); //running
		
		Thread t2 = new Thread(new MyRunnableThread());
		t2.start();
		
		Thread t3 = new Thread(new MyRunnableThread()) {
			public void run() {
				System.out.println("anonymous thread running.");
			};
		};
		t3.start();
	}
	
	static class MyRunnableThread implements Runnable {

		@Override
		public void run() {
			// TODO Auto-generated method stub
			System.out.println("MyRunnableThread running.");
		}
		
	}
	
	static class MyThread extends Thread {
		
		
		@Override
		public void run() {
			String currentThreadName = Thread.currentThread().getName();
			System.out.println("current threading: "+ currentThreadName);
			// TODO Auto-generated method stub
			System.out.println("MyThread running.");
		}
	}
	
	
}



